package com.bluefox.exception;

import org.springframework.util.StringUtils;

/**
 * @CLassName EntityExistException
 * @Description TODO
 * @Author 孙峰
 * @Date 2020/1/2 23:22
 * @Version 1.0
 */
public class EntityExistException extends RuntimeException {
    public EntityExistException(Class clazz, String field, String val) {
        super(EntityExistException.generateMessage(clazz.getSimpleName(), field, val));
    }

    private static String generateMessage(String entity, String field, String val) {
        return StringUtils.capitalize(entity)
                + " with " + field + " "+ val + " existed";
    }
}
